home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / scroll_down.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  2KB  |  65 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include "rec.h"
  20. #include "window.h"
  21. #include "ed_dec.h"
  22.  
  23. /******************************************************************************\
  24. |Routine: scroll_down
  25. |Callby: bigger_win change_case fix_botrec fix_display remove_win smaller_win
  26. |Purpose: Scrolls the current window down if possible. Returns the number
  27. |         of lines actually scrolled.
  28. |Arguments:
  29. |    nscroll is the number of lines to try to scroll.
  30. \******************************************************************************/
  31. Int scroll_down(nscroll)
  32. register Int nscroll;
  33. {
  34.     register Int i,j;
  35.     register rec_ptr r;
  36.  
  37.     if(!nscroll)
  38.         return(0);
  39.     for(r = TOPREC,i = nscroll;r->prev != BASE && i > 0;i--,r = r->prev)
  40.         TOPREC = TOPREC->prev;
  41.     if((i = nscroll - i) > 0)    /* actual number scrollable */
  42.     {
  43.         if(i > BOTROW - TOPROW)
  44.             ref_window(CURWINDOW);
  45.         else
  46.         {
  47.             move(TOPROW,1);
  48.             ins_line(i);
  49.             paint(TOPROW,TOPROW + i - 1,FIRSTCOL);
  50.         }
  51.         for(BOTREC = TOPREC,j = TOPROW;j < BOTROW;j++)
  52.         {
  53.             if(BOTREC == BASE)
  54.             {
  55.                 BOTREC = 0;
  56.                 break;
  57.             }
  58.             else
  59.                 BOTREC = BOTREC->next;
  60.         }
  61.     }
  62.     return(i);
  63. }
  64.  
  65.